
package nu.aing.P20140602;

import nu.aing.utils.TestUtils;

/**
 * @author memekmaut@gmail.com
 */
public class PairGameEasy {

    public static void main(String[] args) {
        PairGameEasy pairGameEasy = new PairGameEasy();
        
        TestUtils.test(pairGameEasy, "able", 1, 2, 3, 5);
        TestUtils.test(pairGameEasy, "able", 1, 2, 2, 1);
        TestUtils.test(pairGameEasy, "able", 2, 2, 2, 999);
        TestUtils.test(pairGameEasy, "able", 2, 2, 2, 1000);
        TestUtils.test(pairGameEasy, "able", 47, 58, 384, 221);
        TestUtils.test(pairGameEasy, "able", 1000, 1000, 1000, 1000);
        
    }

    /**
     * You are given four ints: a, b, c, and d. Return "Able to generate"
     * (quotes for clarity) if it is possible to start with the pair (a, b) and
     * end with the pair (c, d).
     */
    public String able(int a, int b, int c, int d) {
        boolean x = rec(a, b, c, d);
        return (x ? "Able" : "Not able") + " to generate";
    }

    private static boolean rec(int a, int b, int c, int d) {
        if (a == c && b == d)
            return true;
        if (a > c || b > d)
            return false;
        return rec(a + b, b, c, d) || rec(a, a + b, c, d);
    }
}
